package cn.wolfcode.luowowo.comment.domain;

import cn.wolfcode.luowowo.common.util.StringUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 景点评论
 */
@Getter
@Setter
@Document("scenery_comment")
public class SceneryComment implements Serializable {

    public static final int HAS_REPLY_TYPE = 1; //有评论
    public static final int UNHAS_HAS_REPLY_TYPE = 0;//没有评论

    @Id
    private String id;          //默认id
    private Long sceneryId;     //景点id
    private String sceneryName; //景点名称
    private String sceneryUrl; //景点图片
    private String sceneryEnglish; //景点英文名称

    private Long userId;        //用户id
    private String username;    //用户名
    private int userLevel;      //用户等级
    private String headUrl;     //头像

    private Date createTime;    //创建时间

    //private int contentnum;     //评论数
    private int thumbupnum;     //点赞数
    private List<Long> thumbuplist = new ArrayList<>(); //点赞人集合

    private String content;         //评论内容

    private String upload;         //评论图片
    private Integer statNum;        //总体评价
    /*private Integer sceneryNum;     //风景评价
    private Integer featuresNum;    //特色评价
    private Integer serviceNum;     //服务评*/

    private int hasReply = UNHAS_HAS_REPLY_TYPE;           //是否有回复

    List<SceneryReply> sceneryReplies; //回复

    //更改回复状态
    public void changReplyType() {
        this.hasReply = HAS_REPLY_TYPE;
    }

    public String getRecommend() {
        if (statNum == 1) {
            return "千万别去";
        } else if (statNum == 2) {
            return "不推荐";
        } else if (statNum == 3) {
            return "一般般";
        } else if (statNum == 4) {
            return "值得一去";
        } else if (statNum == 5) {
            return "必须推荐";
        }
        return null;
    }
    //获取评论图片
    public String[] getImgArr() {
        if (StringUtil.hasLength(upload)) {
            return upload.split(",");
        }

        return null;
    }

}
